#include <stdio.h>

#include "LongRangeScan.h"
#include "Render.h"

LongRangeScan::LongRangeScan()
{
	type = LONGRANGESCAN;

	//Set the position of the sprite info
	lrsSpriteInfo.pos = XY(SCREEN_HEIGHT - (SCREEN_HEIGHT / 5), SCREEN_WIDTH / 8);

	//Set the orientation of the sprite info
	lrsSpriteInfo.orientation = 0;

	//Set the color of the sprite info
	lrsSpriteInfo.color = WHITE;

	//Set the scale of the sprite info
	lrsSpriteInfo.scale = 1;
	
	//Set the size of the clickable object
	setSize(LRS_TOP_LEFT,  LRS_SIZE);

	//Load long range scan texture and set the referance number
	lrsSpriteInfo.reference = Render::getInstance()->LoadTexture("Long Range Scan.png", LRS_SIZE.x, LRS_SIZE.y);
}

void LongRangeScan::Load(Quad** newQuad)
{
	//The LongRangeScan's quads that are being displayed will be set equal to the quads that are sent to it
	//The quads sent to LongRangeScan are determinde by the current quad the player is in
	for(int i = 0; i < BOARD_SIZE; i++)
	{
		quad[i] = newQuad[i];
	}
}

void LongRangeScan::Draw()
{
	//Set the Render object to be used later
	Render* renderer = Render::getInstance();

	//Create a the array for the long range scan numbers
	char lrsNum[STRING_SIZE];

	for(int i = 0; i < LRS_RANGE; i++)
	{
		//Set the font for the character array
		sprintf_s(lrsNum, "%i:%i:%i", quad[i]->getQuadInfo().Enemies, quad[i]->getQuadInfo().Stations, quad[i]->getQuadInfo().Suns);

		//Load the character array into a "text node"
		lrsText.setData(lrsNum, WHITE, XY(SQUARE_SIZE) );

		//Add the text node to the draw list
		renderer->AddToDrawList(&lrsText);
	}

	//Set the long range scan's sprite using the sprite info
	lrsSprite.setData(lrsSpriteInfo);

	//Add the sprite node to the draw list
	renderer->AddToDrawList(&lrsSprite);
}